import freemarker.template.TemplateException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import pro.shuangxi.generator.Generator;
import pro.shuangxi.source.OracleMapSource;

/**
 * @author mengshx
 **/
public class CodeGeneratorOracle {
    public static void main(String[] args) throws IOException, TemplateException {
        String url = "jdbc:oracle:thin:@localhost:1521:helowin";
        String username="sdbmjs23";
        String pwd="sdbmjs23_neusoft";
        String packageName="com.neusoft.user.${tableName}";
        String template = "template_angular14";
        String[] tableNames=new String[]{"FA_JOB","FA_JOB_ROLE"};
        Map<String, String> params = new HashMap<>();
        params.put("bigModuleName", "user");
//        String url = "jdbc:oracle:thin:@124.128.12.154:50902/fsprod";
//        String username="gfa_sd";
//        String pwd="gfa_sd_1020";
//        String packageName="com.neusoft.jn.gfa.dwext";
//        String template = "neusoft-ruoyi-template";
//        String[] tableNames=new String[]{"SD_GFA_DW_V23"};
        doRender(url,username,pwd,packageName,tableNames,template,params);
    }

    public static void doRender(String url,String username,String pwd,String packageName,String[] tableNames,String template,Map<String, String> params){

        for (String tableName : tableNames) {
            OracleMapSource source = new OracleMapSource(url,
                username,
                pwd,
                tableName);
//        OracleMapSource source = new OracleMapSource("jdbc:oracle:thin:@localhost:21521:helowin",
//            "sdbmjs23",
//            "sdbmjs23_neusoft",
//            "GFA_DATA");
            source.setAuthor("mengshx");
            source.setPackage(packageName);
            source.getMap().putAll(params);
            Generator generator = new Generator(source);
            generator.setOutputPath("render");
            generator.render(template);
        }
    }
}
